package com.AEWMS.Servlet;

import com.AEWMS.Dao.Admin;
import com.AEWMS.Service.AdminService;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author ths
 * @create 2021/3/31 20:29
 */
@WebServlet(name = "InsertClassAdminServlet", urlPatterns = "/InsertClassAdminServlet")
public class InsertClassAdminServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String  AdminStudentNumber = request.getParameter("p1");
//        String password = request.getParameter("p2");
        String studentRealName = request.getParameter("p3");
        String studentSex = request.getParameter("p4");
        String studentTel = request.getParameter("p5");
//        String type = request.getParameter("p6");
        String studentNumber = request.getParameter("p7");
        AdminService as = new AdminService();
        Admin a = new Admin();
        a.setAdminId(AdminStudentNumber);
        a.setAdminName(studentRealName);
        a.setAdminSex(studentSex);
        a.setAdminTel(studentTel);
        a.setStuNum(studentNumber);
        if(as.insertClassAdm(a)){
            response.getWriter().println(JSON.toJSONString("设置成功"));
            return;
        }else{
            response.getWriter().println(JSON.toJSONString("设置失败"));
        }
        as.closeCon();


    }
}
